From ed55c696cd083bfaa5429082a9c5edd4ebde0cd8 Mon Sep 17 00:00:00 2001 From: Sebastien Castiel Date: Tue, 5 Dec 2023 17:39:05 -0500 Subject: First version --- src/app/groups/[groupId]/page.tsx | 141 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100644 src/app/groups/[groupId]/page.tsx (limited to 'src/app/groups/[groupId]/page.tsx') diff --git a/src/app/groups/[groupId]/page.tsx b/src/app/groups/[groupId]/page.tsx new file mode 100644 index 0000000..1577d7a --- /dev/null +++ b/src/app/groups/[groupId]/page.tsx @@ -0,0 +1,141 @@ +import { SaveGroupLocally } from '@/app/groups/[groupId]/save-recent-group' +import { Badge } from '@/components/ui/badge' +import { Button } from '@/components/ui/button' +import { + Card, + CardContent, + CardDescription, + CardHeader, + CardTitle, +} from '@/components/ui/card' +import { + Table, + TableBody, + TableCell, + TableHead, + TableHeader, + TableRow, +} from '@/components/ui/table' +import { getGroup, getGroupExpenses } from '@/lib/api' +import { ChevronLeft, ChevronRight, Edit, Plus } from 'lucide-react' +import Link from 'next/link' +import { notFound } from 'next/navigation' + +export default async function GroupPage({ + params: { groupId }, +}: { + params: { groupId: string } +}) { + const group = await getGroup(groupId) + if (!group) notFound() + + const expenses = await getGroupExpenses(groupId) + + return ( +
+
+ + +
+ +

{group.name}

+ + +
+ + Expenses + + Here are the expenses that you created for your group. + + + + + +
+ + + + + Title + Paid by + Paid for + Amount + + + + + {expenses.map((expense) => ( + + {expense.title} + + + { + group.participants.find( + (p) => p.id === expense.paidById, + )?.name + } + + + + {expense.paidFor.map((paidFor, index) => ( + + { + group.participants.find( + (p) => p.id === paidFor.participantId, + )?.name + } + + ))} + + + $ {expense.amount.toFixed(2)} + + + + + + ))} + +
+
+
+ + + + Participants + + +
    + {group.participants.map((participant) => ( +
  • {participant.name}
  • + ))} +
+
+
+ +
+ ) +} -- cgit v1.3